package ru.amse.baltijsky.javascheme.tree;

import ru.amse.baltijsky.javascheme.nodeshape.ActionNodeShape;
import ru.amse.baltijsky.javascheme.nodeshape.INodeShape;

/**
 * Represents a situation when the program flow continues looping the enclosing block before approaching its end.
 * As of the current version, no labeled form is supported.
 *
 * @todo Consider labeled <code>continue</code>.
 */
public class ContinueNode extends FlowChangeNode {
    /**
     * Default constructor. Creates a node without previous or parent (nesting) node.
     */
    public ContinueNode() {
        super();
    }

    /**
     * Constructor. Initializes the nesting link and sets <code>.next</code> link in the previous node.
     *
     * @param parentNode the node that nests our node
     * @param prevNode   the node for which to set the <code>.next</code> link
     */
    public ContinueNode(SchemaNode parentNode, SchemaNode prevNode) {
        super(parentNode, prevNode);
    }

    /**
     * Constructs a new node without previous or nesting node and with information about the corresponding code.
     *
     * @param s code associated with the node
     */
    public ContinueNode(String[] s) {
        super(s);
    }

    /**
     * Constructs a new node with full information about the nesting and previous nodes and the corresponding code.
     *
     * @param parentNode link to the parent (nesting) node
     * @param prevNode   link to the node that is previous in the sense of program flow
     * @param s          code associated with the node
     */
    public ContinueNode(SchemaNode parentNode, SchemaNode prevNode, String[] s) {
        super(parentNode, prevNode, s);
    }

    public INodeShape getShape() {
        return new ActionNodeShape(getCodeAsString());
    }

    public NodeType getNodeType() {
        return NodeType.CONTINUE;
    }
}